
<#include "header.ftl">
<link rel="stylesheet" href="${Domain}common/amazeui/css/amazeui.datatables.min.css" />
<script src="${Domain}common/amazeui/js/amazeui.datatables.min.js"></script>
  <!-- 内容区域 -->
<div class="tpl-content-wrapper">

   <div class="container-fluid am-cf">
                <div class="row">
                   <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                        <ol class="am-breadcrumb">
						  <li><a href="${Domain}my" class="am-icon-home">首页</a></li>
						  <li ><a href="${Domain}my/question/list/${question.type}"><#if question.type=0>判断</#if><#if question.type=1>单选</#if><#if question.type=2>多选</#if><#if question.type=3>填空</#if><#if question.type=4>自填</#if></a></li>
						  <li class="am-active">编辑</li>
						</ol>
                    </div>
                  	<#include "../common/return.ftl">
                </div>
</div>
  <div class="row-content am-cf">
  
  

          <div class="row">

                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">编辑问题</div>
                                
                            </div>
                            <div class="widget-body am-fr">

                                <form class="am-form tpl-form-line-form"  method="post" action="${Domain}api/question/update" id="question-update" >
                                    
                                  <input type="hidden" id="id" name="id" value="${question.id}">
                                   
                                   <#if question.type==1||question.type==2>
									 <div class="am-form-group">
                                        <label  class="am-u-sm-3 am-u-md-3 am-form-label">问题类型 </label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                           <select data-am-selected="{btnSize: 'sm'}" name="type" id="type">
										  <option value="1" <#if question.type==1> selected</#if>>单选</option> 
							              <option value="2" <#if question.type==2> selected</#if>>多选</option>				          
										 </select>              
                                        </div>
                                         <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
                                    </#if>
                                   
                                 
                                    <div class="am-form-group">
                                        <label  class="am-u-sm-3 am-u-md-3 am-form-label">问题标签 </label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                            <input type="text" class="tpl-form-input" id="tag" name="tag" placeholder="标签" value="${question.tag}" />                                   
                                        </div>
                                         <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
                                     <div class="am-form-group">
                                        <label  class="am-u-sm-3 am-u-md-3 am-form-label">问题标题 </label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                            <input type="text" class="tpl-form-input" id="title" name="title" value="${question.title}" placeholder="请输入问题标题"  required/>                                   
                                        </div>
                                         <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
                                    
                                    <div class="am-form-group">
                                        <label  class="am-u-sm-3 am-u-md-3 am-form-label">问题名称 </label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                            <input type="text" class="tpl-form-input" id="name" name="name" value="${question.name}" placeholder="请输入问题名称"  required/>                                   
                                        </div>
                                         <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
                                   
                                    <#if question.type==0>
									 <div class="am-form-group">
                                        <label  class="am-u-sm-3 am-u-md-3 am-form-label">默认值 </label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                           <select data-am-selected="{btnSize: 'sm'}" name="value" id="value">
										  <option value="0" <#if question.value==0>selected</#if>>否</option> 
							              <option value="1" <#if question.value==1>selected</#if>>是</option>				          
										 </select>              
                                        </div>
                                         <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
                                    </#if>
                                     <#if question.type==3||question.type==1||question.type==2>
									 <div class="am-form-group">
                                        <label  class="am-u-sm-3 am-u-md-3 am-form-label">默认值 </label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                           <input type="text" class="tpl-form-input" id="value" name="value" value="${question.value}" placeholder="请输入默认"  required/>                                 
                                        </div>
                                        <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
                                    </#if>
                                    <div class="am-form-group">
                                        <label  class="am-u-sm-3 am-u-md-3 am-form-label">问题条件 </label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                            <select multiple data-am-selected="{btnWidth: '80%',searchBox: 1,btnSize: 'sm',maxHeight: 240}" name="filters">											  
											  <#list list0 as item>
											    <option value="${item.id}"   <#list filters as i> <#if i.id==item.id>selected </#if> </#list>>${item.name}</option>
											  </#list>
											</select>                                
                                        </div>
                                         <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>                                  
                                    <div class="am-form-group">
                                        <div class="am-u-sm-6 am-u-sm-push-3">
                                            <button type="submit" id="sub" class="am-btn page-header-button tpl-btn-bg-color-success am-btn-block">保存</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
        
         
        
            
   </div>
</div>        

<script type="text/javascript">
  var loading; 
$(function() {
 /**
  $('#my-table').DataTable({
  	responsive: true,
  	dom: 'ftp'
 });
 **/
  $('#question-update').validator({
    onValid: function(validity) {   
      $(validity.field).closest('.am-form-group').find('.am-alert').hide();
    },
    onInValid: function(validity) {
   
      var $field = $(validity.field);
      var $group = $field.closest('.am-form-group');
      var $tpl = $group.find('.tpl-form-input');
      var $alert = $group.find('.am-alert');
      // 使用自定义的提示信息 或 插件内置的提示信息
      var msg = $tpl.data('validationMessage') || this.getValidationMessage(validity);
      if (!$alert.length) {
        $alert = $('<div class="am-alert am-alert-danger"></div>').hide().
          insertAfter($tpl);
      }

      $alert.html(msg).show();
    }
  });
});
  
  
   $('#question-update').ajaxForm({
	    beforeSubmit: function(a,f,o) {
	        loading=weui.loading('数据加载中...');
	    },
	    success: function(json) {	    	
	    	if(json.status)
	    	{
	    	  	if(loading)loading.hide();
	    		weui.toast(json.msg); 
	
	    		<#if ask.url??>
	    		location.href="${ask.url}";	
	    		</#if>		
	    		
	    	}else
	    	{	
	    		if(loading)loading.hide();
	    	    weui.alert(json.msg);  		 
	    	}
	    }
	});
	</script>
<#include "footer.ftl">